unit uSBDUnit_SampleExec1;
interface
uses uSBDUnit_Executive;

type

TSampleExec1 = class( TSBDUnit_Executive)
  protected
    procedure   AcquireController;           override;
    procedure   AcquireViews;                override;
    procedure   RegisterAllTestSuites;       override;
  end;

implementation





uses uSBDUnit_SampleTests1, Classes, uSBDUnit_Engine, SysUtils;

type
TController = class( TInterfacedPersistent, IController_FromExecutive,
    IEngineCallbackToController)
  private
    FEngine: ITestEngine;

    procedure Register_SBDUnit_Engine( const Engine: ITestEngine);
    procedure DereferenceEngine( const Engine: ITestEngine);
    procedure ActionEnableStatesChanged( const Engine: ITestEngine);
    procedure Notify_MainControlPropertiesChanged( const Engine: ITestEngine);
      // The Status of the root node changed.
    procedure OnMainFormDestroy( Sender: TObject);

  public
  end;


TView = class( TInterfacedObject, IView_FromExecutive, IView)
  private
    FEngine: ITestEngine;

    procedure Notify_EnginePropsChanged( const Engine: ITestEngine);
    procedure Register_SBDUnit_Engine( const Engine: ITestEngine; isPrimaryView: boolean);
    procedure DereferenceEngine( const Engine: ITestEngine);
    procedure Notify_AddedNode( const Engine: ITestEngine; const NewModelNode: ITestNode);
    procedure Notify_RemovedNode( const Engine: ITestEngine; const ModelNode: ITestNode);
    procedure Notify_MainViewPropertiesChanged( const Engine: ITestEngine; const ModelNode: ITestNode);
    // At least one of .... changed
    // TestResult
    // Enabled
    // Status
    // ExecutionStartTime
    // ExecutionDuration
    // FailCount
    // ExecuteCount
    procedure Notify_NonFailMessageSet( const Engine: ITestEngine; const ModelNode: ITestNode);
    procedure Notify_GeneralCleared( const Engine: ITestEngine; const ModelNode: ITestNode);
  // Cover-all for the following changes.
    // TestResult = trNull
    // Status = sReady
    // FailMessage = ''
    // NonFailMessages cleared
    // ExecutionStartTime = 0.0
    // ExecutionDuration = 0.0
    // FailCount = 0
    // ExecuteCount = 0

    procedure Notify_NonFailMessageLogged(
      const Engine: ITestEngine; const ModelNode: ITestNode; MsgIdx: integer);
    procedure ShutDown;

  public
  end;


{ TSampleExec1 }

procedure TSampleExec1.AcquireController;
var
  Ctrl: TController;
  CtrlF: IController_FromExecutive;
begin
Ctrl := TController.Create;
if Supports( Ctrl, IController_FromExecutive, CtrlF) then
  FController := CtrlF
end;


procedure TSampleExec1.AcquireViews;
var
  View: TView;
  ViewF: IView_FromExecutive;
begin
View := TView.Create;
FViews.Clear;
if Supports( View, IView_FromExecutive, ViewF) then
  FViews.Add( ViewF)
end;



procedure TSampleExec1.RegisterAllTestSuites;
begin
RegisterTestSuites( uSBDUnit_SampleTests1.
  Sample1_RegisterTestSuites)
end;

{ TController }

procedure TController.ActionEnableStatesChanged( const Engine: ITestEngine);
begin

end;

procedure TController.DereferenceEngine( const Engine: ITestEngine);
begin

end;

procedure TController.Notify_MainControlPropertiesChanged(
  const Engine: ITestEngine);
begin

end;

procedure TController.OnMainFormDestroy( Sender: TObject);
begin

end;

procedure TController.Register_SBDUnit_Engine( const Engine: ITestEngine);
begin

end;

{ TView }

procedure TView.DereferenceEngine( const Engine: ITestEngine);
begin

end;

procedure TView.Notify_AddedNode(
  const Engine: ITestEngine; const NewModelNode: ITestNode);
begin

end;

procedure TView.Notify_EnginePropsChanged(const Engine: ITestEngine);
begin

end;

procedure TView.Notify_GeneralCleared(
  const Engine: ITestEngine; const ModelNode: ITestNode);
begin

end;

procedure TView.Notify_MainViewPropertiesChanged(
  const Engine: ITestEngine; const ModelNode: ITestNode);
begin

end;

procedure TView.Notify_NonFailMessageLogged(
  const Engine: ITestEngine; const ModelNode: ITestNode; MsgIdx: integer);
begin

end;

procedure TView.Notify_NonFailMessageSet(
  const Engine: ITestEngine; const ModelNode: ITestNode);
begin

end;

procedure TView.Notify_RemovedNode(
  const Engine: ITestEngine; const ModelNode: ITestNode);
begin

end;

procedure TView.Register_SBDUnit_Engine(
  const Engine: ITestEngine; isPrimaryView: boolean);
begin

end;

procedure TView.ShutDown;
begin

end;

end.
